/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chating;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Andi
 */
public class Duet {
    private String user1;
    private String user2;
    private ArrayList<Message> messages;
    private database.Database db = new database.Database();

    //constructor
    public Duet(){
        this.messages = new ArrayList<Message>();
    }
    public Duet(String userA, String userB){
        try {
            if (db.getUserID(userB) < db.getUserID(userA)) {
                this.user1 = userB;
                this.user2 = userA;
            }else{
                this.user1 = userA;
                this.user2 = userB;
            }
            this.messages = new ArrayList<Message>();
        } catch (SQLException ex) {
            Logger.getLogger(Duet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public Duet(Duet d){
        this.user1 = d.getUser1();
        this.user2 = d.getUser2();
        this.messages = d.getMessages();
        this.db = d.getDb();
    }

    //getter and setter
    /**
     * @return the user1
     */
    public String getUser1() {
        return user1;
    }

    /**
     * @param user1 the user1 to set
     */
    public void setUser1(String user1) {
        this.user1 = user1;
    }

    /**
     * @return the user2
     */
    public String getUser2() {
        return user2;
    }

    /**
     * @param user2 the user2 to set
     */
    public void setUser2(String user2) {
        this.user2 = user2;
    }

    /**
     * @return the messages
     */
    public ArrayList<Message> getMessages() {
        return messages;
    }

    /**
     * @param messages the messages to set
     */
    public void setMessages(ArrayList<Message> messages) {
        this.messages = messages;
    }

    /**
     * @return the db
     */
    public database.Database getDb() {
        return db;
    }

    /**
     * @param db the db to set
     */
    public void setDb(database.Database db) {
        this.db = db;
    }

    //methods
    public void addMessage(String userName, String content){
        Message m = new Message();
    }


}
